package controller;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import model.Message;
import service.MessageService;
import service.impl.MessageServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;

/**
 * @author gzp
 * @create 2023-01-05 19:08
 */
@WebServlet("/message/insert")
public class MessageInsertServlet extends HttpServlet {

    MessageService messageService = new MessageServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置字符格式
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        Message message = new Message();
        message.setUid(Long.parseLong(req.getParameter("uid")));
        message.setSid(Long.parseLong(req.getParameter("sid")));
        message.setDesc(req.getParameter("desc"));
        messageService.insert(message);
    }
}
